class TreeNode:
    def __init__(self, x):
        self.val = x
        self.left = None
        self.right = None

class Solution:
    def inorderTraversal(self, root: TreeNode):
        queue=[root]
        route=[]
        while len(queue)!=0:
            if queue[-1].left is not None and queue[-1].left not in route:
                queue.append(queue[-1].left)
                continue
            node=queue.pop(-1)
            route.append(node)
            if node.right is not None:
                queue.append(node.right)
        return [i.val for i in route]
        
            